package com.example.mapper;

import com.example.pojo.User;
import org.apache.ibatis.annotations.*;

/**
 * @Description TODO
 * @Author fantasy
 * @Date 2024/6/26 22:09
 **/


@Mapper
public interface UserMapper {

    @Select("select * from big_user where username = #{username}")
    User findByUsername(String username);
    @Insert("insert into big_user(username,password,create_time,update_time) values(#{username},#{password},now(),now())")
    void addUser(User user);

    @Update("update big_user set nickname = #{nickname},email = #{email},update_time = now() where id = #{id}")
    void update(User user);

    /**
     * @param avatarUrl
     * @param id
     * @return void
     * @description 更新头像，如果是多个入参，单独更新pojo的某个属性，则需要对所有参数都使用@Param注解
     */
    @Update("update big_user set user_pic = #{avatarUrl},update_time = now() where id = #{id}")
    void updateAvatar(@Param("avatarUrl") String avatarUrl, @Param("id") Integer id);
}
